﻿

Public Class Location

    Sub New(ByVal X As Integer, ByVal Y As Integer)
        Me.X = X
        Me.Y = Y
    End Sub

    Property X As Integer
    Property Y As Integer

    Public Function Distance(ByVal l As Location) As Integer
        Return Math.Abs(Me.X - l.X) + Math.Abs(Me.Y - l.Y)
    End Function

    Public Overrides Function Equals(ByVal obj As Object) As Boolean
        If Type.GetType(obj).Equals(GetType(Location)) Then
            Return False
        End If
        Dim t As Location = TryCast(obj, Location)
        If t.X <> Me.X OrElse t.Y <> Me.Y Then
            Return False
        Else
            Return True
        End If
    End Function

End Class
